#ifndef __LIBMODBUS_RTU_SLAVE__H__
#define __LIBMODBUS_RTU_SLAVE__H__
#include "modbus.h"
#include "modbus-private.h"
#include "modbus-rtu-private.h"
typedef struct
{
	/*rtu */
	modbus_t *rtu_slave_ctx;
	/*tcp */
	modbus_t *tcp_slave_ctx;
	/*rtu/tcp 数据map*/
	modbus_mapping_t *slave_mapping;

	uint8_t rtu_addr;
} modbus_slave_t;
typedef enum
{
	Typetab_tab = 1,
	Typetab_input,
	Typetab_re,
	Typetab_input_re
} Type;

extern modbus_slave_t *modbus_slave_ctx;
modbus_slave_t *modbus_slave_creat(void *rtu_ctx, uint8_t slave_addr);
void modbus_rtu_init(uint8_t addr);
uint16_t modbus_rtu_handle(void *ctx, void *data, uint16_t count);
int modbus_choose_send(uint8_t ch);
uint16_t slave_update(modbus_mapping_t *tab_map, uint8_t *tab, uint8_t *tab_input, uint16_t *tab_re, uint16_t *tab_input_re, uint8_t len);
uint16_t slave_update_type(modbus_mapping_t *ctx, Type type, void *desnt, uint8_t len);
uint8_t arry_length(void *arry, uint8_t a);
extern uint8_t tab[10];
extern uint8_t tab_input[10];
extern uint16_t tab_re1[10];
extern uint16_t tab_input_re[10];
#endif
